package com.zlm.design.observer;

import java.util.function.Consumer;

/**
 * @author zlm
 * @date 2025/5/23
 */
public class User implements EventListener {

    private final String name;

    public final Consumer<String> consumer;

    public User(String name,Consumer<String> consumer) {
        this.name = name;
        this.consumer = consumer;
    }


    public void receiveInfo(String info) {
        consumer.accept(info);
    }

    @Override
    public void onEvent(Event event) {
        if(event instanceof WeatherUpdateEvent){
            receiveInfo(event.source().toString());
        }
    }
}
